package com.masu.knows.sys.controller;

import com.masu.knows.commons.model.Permission;
import com.masu.knows.commons.model.Role;
import com.masu.knows.commons.model.User;
import com.masu.knows.sys.mapper.UserMapper;
import com.masu.knows.sys.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author susi
 * @date 2022/5/16
 */
@RestController
@RequestMapping(value = "/v1/auth")
public class AuthController {
    @Autowired
    private IUserService userService;


    @GetMapping("/demo")
    public String demo(){
        return "sys:Hello World!!!";
    }

    @GetMapping("/user")
    public User getUser(String username){
        return userService.getUserByUsername(username);
    }

    @GetMapping("/permissions")
    public List<Permission> permissions(Integer id){
        return userService.getPermissionsById(id);
    }

    @GetMapping("/roles")
    public List<Role> roles(Integer id){
        return userService.getRolesById(id);
    }


}
